<template>
  <div class="app-container">
    <h4>退回</h4>
    <!-- 退回 -->
    <el-form label-width="120px">
      <el-form-item label="退回原因" style="width: 600px">
        <el-input
          type="textarea"
          autosize
          v-model="cpHitch.returnContent"
        ></el-input>
      </el-form-item>

      <el-form-item>
        <router-link
          :to="'/charging-pile/hitch_manager'"
          style="margin-right: 5px"
        >
          <el-button type="default" size="small" style="margin-right: 50px">
            返回
          </el-button>
        </router-link>
        <el-button
          :disabled="saveBtnDisabled"
          type="primary"
          size="small"
          @click="save()"
        >
          确定
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
//引入api模块
import listApi from '@/api/charging-pile/hitch_manage'
export default {
  data() {
    //let BASE_API = process.env.BASE_API || 'http://localhost:8130'
    return {
      saveBtnDisabled: false, //是否禁用保存按钮，防止表单重复提交
      cpHitch: {
        id: 0,
        returnContent: null,
      }, //故障管理
    }
  },
  created() {},

  methods: {
    //保存
    save() {
      this.cpHitch.id = this.$route.params.id
      console.log(this.cpHitch.id)
      //禁用保存按钮
      this.saveBtnDisabled = true
      listApi
        .cpHitchManagerReturnFirst(this.cpHitch, this.cpHitch.id)
        .then((response) => {
          this.$message.success(response.message)
          this.$router.push('/charging-pile/hitch_manager') //路由地址进行改变
        })
    },
  },
}
</script>
